package com.ltmonitor.web.controller.command;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ltmonitor.entity.TerminalCommand;
import com.ltmonitor.service.JT808Constants;
import com.ltmonitor.web.util.JsonMessage;

/**
 * 终端点名
 * 
 * @author admin
 * 
 */
@Controller
@RequestMapping("/callTerminal")
public class TerminalCallAction extends TerminalCommandAction {

	@RequestMapping("/view.action")
	public String view(long vehicleId, Model m)
	{
		m.addAttribute("vehicleId", vehicleId);
		return "/command/callTerminal";
	}

	// 点名
	@ResponseBody
	@RequestMapping("/send.action")
	public JsonMessage callNow(long vehicleId) {
		try {
			TerminalCommand tc = new TerminalCommand();
			tc.setCmdType(JT808Constants.CMD_REAL_MONITOR);
			tc.setVehicleId(vehicleId);
			SendCommand(tc);

			return json(true, tc.getEntityId());
		} catch (Exception ex) {
			return json(false, ex.getMessage());
		}
	}

}
